import {reqPostSearchGoodsInfoData} from '@/api'

const state = {
  goodsInfo : {}
}

const actions = {
  async postSearchGoodsInfoData({commit},searchParams) {
    const result = await reqPostSearchGoodsInfoData(searchParams)
    // console.log(result);
    if(result.code === 200){
      commit('SAVE_SEARCH_GOODS_INFO_DATA',result.data)
      // console.log(result.data);
    } else {
      console.log(result.message);
    }
  }
}
const mutations = {
  // 存储搜索到的商品到state
  SAVE_SEARCH_GOODS_INFO_DATA(state,goodsInfo) {
    state.goodsInfo = goodsInfo
  }
}

const getters = {
  // 1 商品列表数据
   goodsList(state) {
    return state.goodsInfo.goodsList
  },
  // 属性列表
  attrsList(state) {
    return state.goodsInfo.attrsList
  },

  // 商品品牌列表
  trademarkList(state) {
    return state.goodsInfo.trademarkList
  },
  // 4 商品总数量
  total(state) {
    return state.goodsInfo.total
  },
  
}

export default {
  namespaced:true,
  state,
  actions,
  mutations,
  getters
}